# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=jaraco.itertools
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=6.4.3
pkgrel=1
pkgdesc='Jaraco Itertools (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/jaraco-itertools'
)
url="https://github.com/jaraco/jaraco.itertools"
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python-more-itertools"
  "${MINGW_PACKAGE_PREFIX}-python-inflect"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/./_}/${_realname/./_}-${pkgver}.tar.gz")
sha256sums=('06c8727afcad659e29ce78773870428500f4daf6f13b9c2f5154ddb21cbca90d')

build() {
  export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"
  cp -r "${_realname/./_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
